#ifndef _GDIPLUS_INIT_
#define _GDIPLUS_INIT_

#include <gdiplus.h>
#pragma comment(lib, "gdiplus.lib")



class CGdiPlusInit
{
public:
	CGdiPlusInit() throw():m_dwToken(0)	{Init();};
	~CGdiPlusInit() throw()	{Exit();};

	bool Init() throw()
	{
		using namespace Gdiplus;
		if(m_dwToken==0)
		{
			GdiplusStartupInput Input;
			GdiplusStartupOutput output;
			Status status = GdiplusStartup(&m_dwToken, &Input, &output);
			if(status!=Ok)	return false;
		}
		return true;
	};

	void Exit() throw()
	{
		using namespace Gdiplus;
		if(m_dwToken!=0)
		{
			GdiplusShutdown(m_dwToken);
		}
	};

private:
	ULONG_PTR m_dwToken;
};

#endif